<%@ page language="java" contentType="text/html; charset=UTF-8" %>

<%@ page import="weaver.general.BaseBean" %>
<%@ page import="org.dom4j.Document" %>
<%@ page import="org.dom4j.DocumentHelper" %>
<%@ page import="org.dom4j.Element" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.io.*" %>
<%
    new BaseBean().writeLog("测试222");
    String responseXml = "<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:sap-com:document:sap:soap:functions:mc-style\">\n" +
            "  <soapenv:Header/>\n" +
            "  <soapenv:Body><Type>S</Type><Message>测试</Message><Type>E</Type><Message>测试12</Message>  </soapenv:Body>\n" +
            "</soapenv:Envelope>";
   // byte[] byteFile=getBytes("d:/Demo.xml");
   // new BaseBean().writeLog("测试111:"+byteFile);
    //  byte[] byteFile=getBytes("d:/test_update.xml");
    //("")内容传值得xml内容即可（test_create11.xml内容），删除注释
 //   String responseXml=new String(byteFile, "UTF-8");
    new BaseBean().writeLog(responseXml);
    Document doc = null;
    try {
        doc = DocumentHelper.parseText(responseXml);
        Iterator<Element> its2 = doc.selectNodes("//Type").iterator();
        Iterator<Element> its3 = doc.selectNodes("//Message").iterator();
        while (its2.hasNext() && its3.hasNext()) {
            Element element = its2.next();
            Element element2 = its3.next();
            String testType = element.getText();
            String mess = element2.getText();
            new BaseBean().writeLog("type:"+testType);
            new BaseBean().writeLog("mess:"+mess);
//
//            if (!"".equals(testType) && "S".equals(testType)) {
//                boolean isSuccess = true;
//                //  bb.writeLog("testType值为:" + testType + "\n");
//                break;
//            }

        }




    } catch (Exception e) {
        e.printStackTrace();
    }
%>
<%!


    /**
     * 获得指定文件的byte数组
     */
    public static byte[] getBytes(String filePath){
        byte[] buffer = null;
        try {
            File file = new File(filePath);
            FileInputStream fis = new FileInputStream(file);
            ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);
            byte[] b = new byte[1000];
            int n;
            while ((n = fis.read(b)) != -1) {
                bos.write(b, 0, n);
            }
            fis.close();
            bos.close();
            buffer = bos.toByteArray();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return buffer;
    }
%>